home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / Feelin021015 / Libs / Feelin / Shade.e < prev    next >
Text File  |  2002-10-28  |  22KB  |  779 lines

  1. OPT PREPROCESS,OSVERSION=39
  2.  
  3. MODULE  'intuition/intuition','intuition/intuitionbase','intuition/screens','intuition/classes','intuition/imageclass','intuition/gadgetclass','intuition/classusr',
  4.         'graphics/rastport','graphics/text',
  5.         'utility','utility/tagitem','utility/hooks',
  6.         'feelin','libraries/feelin','a4'
  7.  
  8. LIBRARY  'Shade.wr',1,02,'Feelin: Shade window renderer 1.02 (02-02-01) by Olivier Laviale (lotan9@aol.com)' IS class_Info(A0)
  9.  
  10. ->PROC OBJ
  11. OBJECT classuserdata
  12.    imageclass:PTR TO iclass
  13. ENDOBJECT
  14. ->ENDPROC
  15.  
  16. DEF cud:PTR TO classuserdata
  17.  
  18. PROC main() IS sys_SGlob()
  19. OBJECT mydata OF feelinWindowRenderer
  20.    font:PTR TO textfont
  21.    pens:PTR TO LONG
  22.    prep:PTR TO CHAR
  23.  
  24.    activepens:PTR TO LONG
  25.    inactivepens:PTR TO LONG
  26.  
  27.    aprep:PTR TO CHAR
  28.    iprep:PTR TO CHAR
  29.  
  30.    gadw:INT,gadh:INT
  31.  
  32.    image_close,image_iconify,image_zoom,image_depth
  33.    button_close,button_iconify,button_zoom,button_depth,button_dragbar,button_size
  34.    textdisplay:PTR TO feelinObject
  35.  
  36.    barrect:feelinRect
  37.    handler:feelinEventHandler
  38. ENDOBJECT
  39.  
  40. OBJECT myimagedata
  41.    renderer:PTR TO mydata
  42.    type:INT
  43. ENDOBJECT
  44.  
  45. ENUM FV_GadgetType_Close = 1,
  46.      FV_GadgetType_Iconify,
  47.      FV_GadgetType_Zoom,
  48.      FV_GadgetType_Depth
  49.  
  50. CONST TICKNESS = 5,
  51.       TITLEX1  = 10, TITLEY1 = 3,
  52.       TITLEX2  = 10, TITLEY2 = 3
  53.  
  54. CONST SIZE = TICKNESS * 4
  55.  
  56. CONST FM_Renderer_TitleBar = FCCM_BASE
  57.  
  58. #define _Box(x1,y1,x2,y2) priv_Box(rp,x1,y1,x2,y2)
  59.  
  60. ->ENDPROC
  61.  
  62. PROC class_Info      (feelin:PTR TO feelinbase)
  63.    feelinbase  := feelin
  64.    utilitybase := feelin.utility
  65.  
  66.    SetStdOut(feelin.console)
  67.  
  68.    RETURN  [FA_DataSize,   SIZEOF mydata,
  69.             FA_Dispatcher, {class_Dispatcher},
  70.             FA_ClassInit,  {class_Init},
  71.             FA_ClassExit,  {class_Exit},
  72.             NIL]
  73. ENDPROC
  74. PROC class_Init      (class=A2:PTR TO feelinClass)
  75.    DEF ic:PTR TO iclass
  76.  
  77.    sys_RGlob()
  78.  
  79.    IF cud := F_New(SIZEOF classuserdata)
  80.       IF ic := MakeClass(NIL,'imageclass',NIL,SIZEOF mygaddata,NIL)
  81.          ic.dispatcher.entry := {image_dispatcher}
  82.          cud.imageclass := ic
  83.  
  84.          RETURN class.userdata := cud
  85.       ENDIF
  86.  
  87.       cud := F_Dispose(cud)
  88.    ENDIF
  89. ENDPROC
  90. PROC class_Exit      (class=A2:PTR TO feelinClass)
  91.    sys_RGlob()
  92.  
  93.    IF cud := class.userdata
  94.       cud.imageclass := RemoveClass(cud.imageclass) BUT NIL
  95.       cud := F_Dispose(cud)
  96.    ENDIF
  97. ENDPROC
  98. PROC class_Dispatcher(obj=A0:PTR TO mydata,method=D0,args=A1:PTR TO LONG)
  99.    sys_RGlob()
  100.  
  101.    SELECT method
  102.       CASE FM_New;      RETURN   wr_New(obj,args)
  103.       CASE FM_Dispose;           wr_Dispose(obj)
  104.  
  105.       CASE FM_Setup;    RETURN   wr_Setup(obj,args)
  106.       CASE FM_Cleanup;  RETURN   wr_Cleanup(obj)
  107.       CASE FM_Show;              wr_Show(obj)
  108.       CASE FM_Hide;              wr_Hide(obj)
  109.  
  110.       CASE FM_HandleEvent;RETURN wr_HandleEvent(obj,args::FS_HandleEvent.msg)
  111.  
  112.       CASE FM_Window_Layout;     wr_Layout(obj)
  113.       CASE FM_Window_Draw;       wr_Draw(obj)
  114.       CASE FM_Renderer_TitleBar; wr_DrawTitleBar(obj)
  115.    ENDSELECT
  116. ENDPROC
  117.  
  118. ->-- Methods --<-------------------------------------------------------------
  119.  
  120. PROC wr_New(obj:PTR TO mydata,tags)
  121.    obj.handler.object   := obj
  122.    obj.handler.priority := 10
  123.    obj.handler.events   := IDCMP_ACTIVEWINDOW OR IDCMP_INACTIVEWINDOW
  124.  
  125.    obj.aprep := '`z`n`Sh`Ss`<7>'
  126.    obj.iprep := '`z`n`b`<0>'
  127.  
  128.    IF obj.textdisplay := F_NewObjA(FC_TextDisplay,NIL) THEN RETURN obj
  129. ENDPROC
  130. PROC wr_Dispose(obj:PTR TO mydata)
  131.    obj.textdisplay      := F_DisposeObj(obj.textdisplay)
  132.  
  133.    obj.button_size      := DisposeObject(obj.button_size) BUT NIL
  134.    obj.button_dragbar   := DisposeObject(obj.button_dragbar) BUT NIL
  135.    obj.button_depth     := DisposeObject(obj.button_depth) BUT NIL
  136.    obj.button_zoom      := DisposeObject(obj.button_zoom) BUT NIL
  137.    obj.button_iconify   := DisposeObject(obj.button_iconify) BUT NIL
  138.    obj.button_close     := DisposeObject(obj.button_close) BUT NIL
  139.  
  140.    obj.image_depth      := DisposeObject(obj.image_depth) BUT NIL
  141.    obj.image_zoom       := DisposeObject(obj.image_zoom) BUT NIL
  142.    obj.image_iconify    := DisposeObject(obj.image_iconify) BUT NIL
  143.    obj.image_close      := DisposeObject(obj.image_close) BUT NIL
  144.    
  145.    obj.font             := CloseFont(obj.font) BUT NIL
  146. ENDPROC
  147.  
  148. PROC wr_Setup(obj:PTR TO mydata,s:PTR TO FS_Setup)
  149.    DEF win:PTR TO feelinWindow,handler,dc,
  150.        ic:PTR TO iclass,i:PTR TO image,o:PTR TO object,d:PTR TO myimagedata
  151.  
  152.    IF (obj.render := s.render) = NIL THEN RETURN
  153.    IF (win        := s.render.windowobject) = NIL THEN RETURN
  154.  
  155.    obj.font := F_DoA(obj.render.clientobject,
  156.                      FM_Client_OpenFont,[
  157.                      obj,FP_Renderer_Font])
  158.  
  159.    obj.gadw      := obj.font.ysize + (obj.font.ysize / 3)
  160.    obj.gadh      := obj.font.ysize
  161.    obj.borders.l := 2 + TICKNESS ; obj.borders.r := 2 + TICKNESS
  162.    obj.borders.b := 2 + TICKNESS ; obj.borders.t := 2 + Max(obj.font.ysize,obj.gadh) + TITLEY1 + TITLEY2
  163.  
  164.    IF ic := cud.imageclass
  165. ->PROC Close
  166.       IF WFLG_CLOSEGADGET AND win.winflags
  167.          IF i := NewObjectA(ic,NIL,[IA_WIDTH,obj.gadw, IA_HEIGHT,obj.gadh, NIL])
  168.             obj.image_close := i
  169.  
  170.             d          := i + ic.instoffset
  171.             d.renderer := obj
  172.             d.type     := FV_GadgetType_Close
  173.  
  174.             IF o := NewObjectA(NIL,'buttongclass',[
  175.                GA_WIDTH,obj.gadw,
  176.                GA_HEIGHT,obj.gadh,
  177.                GA_RELVERIFY,TRUE,
  178.                GA_ENDGADGET,TRUE,
  179.                GA_SYSGTYPE,GTYP_CLOSE,
  180.                GA_TOPBORDER,TRUE,
  181.                GA_IMAGE, i, NIL])
  182.  
  183.                obj.button_close := o
  184.             ELSE
  185.                RETURN
  186.             ENDIF
  187.          ELSE
  188.             RETURN
  189.          ENDIF
  190.       ENDIF
  191. ->ENDPROC
  192. ->PROC Depth
  193.       IF WFLG_DEPTHGADGET AND win.winflags
  194.          IF i := NewObjectA(ic,NIL,[IA_WIDTH,obj.gadw, IA_HEIGHT,obj.gadh, NIL])
  195.             obj.image_depth := i
  196.  
  197.             d          := i + ic.instoffset
  198.             d.renderer := obj
  199.             d.type     := FV_GadgetType_Depth
  200.  
  201.             IF o := NewObjectA(NIL,'buttongclass',[
  202.                GA_WIDTH,obj.gadw,
  203.                GA_HEIGHT,obj.gadh,
  204.                GA_RELVERIFY,TRUE,
  205.                GA_SYSGTYPE,GTYP_WDEPTH,
  206.                GA_TOPBORDER,TRUE,
  207.                GA_IMAGE, i, NIL])
  208.  
  209.                obj.button_depth := o
  210.             ELSE
  211.                RETURN
  212.             ENDIF
  213.          ELSE
  214.             RETURN
  215.          ENDIF
  216.       ENDIF
  217. ->ENDPROC
  218. ->PROC DragBar
  219.       IF WFLG_DRAGBAR AND win.winflags
  220.          IF o := NewObjectA(NIL,'buttongclass',[
  221.             GA_TOP,1,
  222.             GA_LEFT,1,
  223.             GA_WIDTH,10,
  224.             GA_HEIGHT, obj.borders.t - 2,
  225.             GA_SYSGTYPE,GTYP_WDRAGGING,
  226.             GA_TOPBORDER, TRUE, TAG_DONE])
  227.  
  228.             obj.button_dragbar := o
  229.          ELSE
  230.             RETURN
  231.          ENDIF
  232.       ENDIF
  233. ->ENDPROC
  234. ->PROC Size & Zoom
  235.       IF WFLG_SIZEGADGET AND win.winflags
  236.          IF i := NewObjectA(ic,NIL,[IA_WIDTH,obj.gadw, IA_HEIGHT,obj.gadh, NIL])
  237.             obj.image_zoom := i
  238.  
  239.             d          := i + ic.instoffset
  240.             d.renderer := obj
  241.             d.type     := FV_GadgetType_Zoom
  242.  
  243.             IF o := NewObjectA(NIL,'buttongclass',[
  244.                GA_WIDTH,obj.gadw,
  245.                GA_HEIGHT,obj.gadh,
  246.                GA_RELVERIFY,TRUE,
  247.                GA_SYSGTYPE,GTYP_WZOOM,
  248.                GA_TOPBORDER,TRUE,
  249.                GA_IMAGE, i, NIL])
  250.  
  251.                obj.button_zoom := o
  252.             ELSE
  253.                RETURN
  254.             ENDIF
  255.          ELSE
  256.             RETURN
  257.          ENDIF
  258.  
  259.          IF o := NewObjectA(NIL,'buttongclass',[
  260.             GA_WIDTH,SIZE,
  261.             GA_HEIGHT,SIZE,
  262.             GA_SYSGTYPE,GTYP_SIZING,
  263.             GA_TOPBORDER, TRUE, TAG_DONE])
  264.  
  265.             obj.button_size := o
  266.          ELSE
  267.             RETURN
  268.          ENDIF
  269.       ENDIF
  270. ->ENDPROC
  271.    ENDIF
  272.  
  273.    IF dc := obj.render.context
  274.       obj.activepens   := F_Get(dc,FA_Display_Scheme)
  275.       obj.inactivepens := F_DoA(dc,FM_Display_CreateScheme,[
  276. /*
  277.                                    FA_Pen_Shine,'s:2',->'s:7',
  278.                                    FA_Pen_Fill, 's:4',->'s:7',
  279.                                    FA_Pen_Dark, 's:6',->'s:7',
  280. */
  281.  
  282.                                    FA_Pen_Shine,'s:7',
  283.                                    FA_Pen_Fill, 's:7',
  284.                                    FA_Pen_Dark, 's:7',
  285.                                    FA_Pen_Text, 's:3',
  286.  
  287.                                    NIL])
  288.       obj.pens := obj.activepens
  289.  
  290.       F_DoA(win,FM_Window_AddEventHandler,(handler := obj.handler) BUT {handler})
  291.  
  292.       F_DoA(win,FM_Notify,[
  293.                 FA_Window_Title,FV_Notify_Always,
  294.                 obj,1,
  295.                 FM_Renderer_TitleBar])
  296.  
  297.       RETURN TRUE
  298.    ENDIF
  299. ENDPROC
  300. PROC wr_Cleanup(obj:PTR TO mydata)
  301.    DEF win,a
  302.  
  303.    IF win := obj.render.windowobject
  304.       F_DoA(win,FM_Window_RemEventHandler,(a := obj.handler) BUT {a})
  305.       F_DoA(win,FM_UnNotifyAttr,[FA_Window_Title])
  306.    ENDIF
  307.  
  308.    F_DoA(obj.render.context,FM_DeleteScheme,(a := obj.inactivepens) BUT {a})
  309.  
  310.    obj.render := NIL
  311.    obj.pens   := NIL
  312. ENDPROC
  313. PROC wr_Show(obj:PTR TO mydata)
  314.    DEF win:PTR TO window,o
  315.  
  316.    IF win := obj.render.window
  317.       wr_Layout(obj)
  318.  
  319.       IF o := obj.button_close   ; AddGadget(win,o,-1) ; win.flags := win.flags OR WFLG_CLOSEGADGET ; ENDIF
  320.       IF o := obj.button_zoom    ; AddGadget(win,o,-1) ; win.flags := win.flags OR WFLG_HASZOOM     ; ENDIF
  321.       IF o := obj.button_depth   ; AddGadget(win,o,-1) ; win.flags := win.flags OR WFLG_DEPTHGADGET ; ENDIF
  322.       IF o := obj.button_size    ; AddGadget(win,o,-1) ; win.flags := win.flags OR WFLG_SIZEGADGET  ; ENDIF
  323.       IF o := obj.button_dragbar THEN AddGadget(win,o,-1)
  324.       IF o := obj.button_iconify THEN AddGadget(win,o,-1)
  325.    ENDIF
  326. ENDPROC
  327. PROC wr_Hide(obj:PTR TO mydata)
  328.    DEF win:PTR TO window
  329.  
  330.    IF win := obj.render.window
  331.       RemoveGadget(win,obj.button_iconify)
  332.       RemoveGadget(win,obj.button_dragbar)
  333.       RemoveGadget(win,obj.button_size)
  334.       RemoveGadget(win,obj.button_zoom)
  335.       RemoveGadget(win,obj.button_depth)
  336.       RemoveGadget(win,obj.button_close)
  337.    ENDIF
  338. ENDPROC
  339.  
  340. PROC wr_HandleEvent(obj:PTR TO mydata,msg:PTR TO intuimessage)
  341.    SELECT msg.class
  342.       CASE IDCMP_ACTIVEWINDOW    ; obj.pens := obj.activepens   ; wr_Draw(obj)
  343.       CASE IDCMP_INACTIVEWINDOW  ; obj.pens := obj.inactivepens ; wr_Draw(obj)
  344.    ENDSELECT
  345. ENDPROC
  346.  
  347. PROC wr_Layout(obj:PTR TO mydata)
  348.    DEF win:PTR TO window,x1,y1,x2,y2,o
  349.  
  350.    win := obj.render.window
  351.  
  352.    y1 := 1 ; y2 := win.height - 1
  353.  
  354.    IF (obj.button_close = NIL) AND (obj.button_iconify = NIL)
  355.       x1 := 1 + TICKNESS
  356.    ELSE
  357.       x1 := 1
  358.  
  359.       IF o := obj.button_close
  360.          Set(o,GA_LEFT,x1 + TICKNESS, GA_TOP,y1 + TITLEY1, NIL)
  361.          x1 := TICKNESS * 2 +  x1 + obj.gadw
  362.       ENDIF
  363.  
  364.       IF o := obj.button_iconify
  365.          Set(o,GA_LEFT,x1 + TICKNESS, GA_TOP,y1 + TITLEY1, NIL)
  366.          x1 := TICKNESS * 2 + x1 + obj.gadw
  367.       ENDIF
  368.    ENDIF
  369.  
  370.    IF (obj.button_zoom = NIL) AND (obj.button_depth = NIL)
  371.       x2 := win.width - 1 - TICKNESS
  372.    ELSE
  373.       x2 := win.width - 1
  374.  
  375.       IF o := obj.button_depth
  376.          Set(o,GA_LEFT,x2 - TICKNESS - obj.gadw, GA_TOP,y1 + TITLEY1,NIL)
  377.          x2 := x2 - (TICKNESS * 2) - obj.gadw
  378.       ENDIF
  379.  
  380.       IF o := obj.button_zoom
  381.          Set(o,GA_LEFT,x2 - TICKNESS - obj.gadw, GA_TOP,y1 + TITLEY1,NIL)
  382.          x2 := x2 - (TICKNESS * 2) - obj.gadw
  383.       ENDIF
  384.    ENDIF
  385.  
  386.    IF o := obj.button_dragbar
  387.       Set(o,GA_LEFT, x1, GA_WIDTH,x2 - x1 - 1, TAG_DONE)
  388.    ENDIF
  389.  
  390.    IF o := obj.button_size
  391.       Set(o,GA_LEFT,win.width - SIZE - 1,
  392.             GA_TOP,win.height - SIZE - 1, NIL)
  393.    ENDIF
  394. ENDPROC
  395. PROC wr_Draw(obj:PTR TO mydata)
  396.    DEF win:PTR TO window,o:PTR TO gadget,rp,pn:PTR TO LONG,
  397.        x1,y1,x2,y2,ix1,iy1,ix2,iy2,p,
  398.        shine,fill,shadow,dark
  399.  
  400.    win := obj.render.window
  401.  
  402.    rp := win.rport
  403.    x1 := 0 ; x2 := win.width - 1    ; ix1 := x1 + obj.borders.l - 1 ; ix2 := x2 - obj.borders.r + 1
  404.    y1 := 0 ; y2 := win.height - 1   ; iy1 := y1 + obj.borders.t - 1 ; iy2 := y2 - obj.borders.b + 1
  405.    pn := obj.pens
  406.  
  407.    shine  := pn[FV_Pen_Shine]
  408.    fill   := pn[FV_Pen_Fill]
  409.    shadow := pn[FV_Pen_Shadow]
  410.    dark   := pn[FV_Pen_Dark]
  411.  
  412.    _APen(dark)    ; _Move(x1,y1)   ; _Draw(x2,y1)   ; _Draw(x2,y2)   ; _Draw(x1,y2)   ; _Draw(x1,y1)
  413.                   ; _Move(ix1,iy1) ; _Draw(ix2,iy1) ; _Draw(ix2,iy2) ; _Draw(ix1,iy2) ; _Draw(ix1,iy1)
  414.  
  415.    INC x1 ; INC y1 ; DEC x2 ; DEC y2
  416.  
  417.    _APen(fill)    ; _Boxf(x1+1,iy1-1,ix1-2,y2-1)
  418.                   ; _Boxf(ix2+2,iy1-1,x2-1,y2-1)
  419.                   ; _Boxf(ix1-1,iy2+2,ix2+1,y2-1)
  420.                   ; _Plot(x1,y2)
  421.                   ; _Plot(ix1-1,iy2+1) ; _Plot(x2,y1)
  422.  
  423.    _APen(shine)   ; _Move(x1,iy1)    ; _Draw(x1,y2-1)
  424.                   ; _Move(ix1,iy2+1) ; _Draw(ix2+1,iy2+1) ; _Draw(ix2+1,iy1)
  425.  
  426.    _APen(shadow)  ; _Move(ix1-1,iy1) ; _Draw(ix1-1,iy2)
  427.                   ; _Move(x1+1,y2)   ; _Draw(x2,y2) ; _Draw(x2,iy1)
  428.  
  429.    IF obj.button_size
  430.       SaveSP(x1) ; SaveSP(y1)
  431.  
  432.       x1 := x2 - SIZE + 1
  433.       y1 := y2 - SIZE + 1
  434.  
  435.       _APen(dark)    ; _Move(x1,iy2 + 1)   ; _Draw(x1,y2)     ; _Move(ix2 + 1,y1) ; _Draw(x2,y1)
  436.       _APen(shine)   ; _Move(ix2 + 1,y1+1) ; _Draw(x2-1,y1+1) ; _Move(x1+1,y2-1)  ; _Draw(x1+1,iy2+1)
  437.       _APen(shadow)  ; _Move(x1-1,iy2+2)   ; _Draw(x1-1,y2-1) ; _Move(ix2+2,y1-1) ; _Draw(x2-1,y1-1)
  438.       _APen(fill)    ; _Plot(x1-1,iy2+1)   ; _Plot(x1+1,y2)   ; _Plot(x2,y1+1)    ; _Plot(ix2+1,y1-1)
  439.  
  440.       LoadSP(y1) ; LoadSP(x1)
  441.    ENDIF
  442.  
  443.    y2 := iy1 - 1
  444.  
  445.    IF (obj.button_close = NIL) AND (obj.button_iconify = NIL)
  446.       _APen(shine)   ; _Move(x1,y2)    ; _Draw(x1,y1)              ; _Draw(ix1-2,y1)
  447.       _APen(shadow)  ; _Move(ix1-1,y2) ; _Draw(ix1-1,y1+1)
  448.       _APen(fill)    ; _Plot(ix1-1,y1) ; _Boxf(x1+1,y1+1,ix1-2,y2) ; x1 := ix1
  449.    ELSE ; p := x1
  450.       IF o := obj.button_close
  451.          p := priv_ClearAround(rp,p,y1,y2,obj,o,fill,TRUE)
  452.          IF obj.button_iconify THEN _APen(fill) BUT _Boxf(p-1,y1,p+1,y2)
  453.       ENDIF
  454.       IF o := obj.button_iconify THEN p := priv_ClearAround(rp,p,y1,y2,obj,o,fill,TRUE)
  455.  
  456.       _APen(shine)   ; _Move(x1,y2)    ; _Draw(x1,y1)  ; _Draw(p-2,y1)
  457.       _APen(shadow)  ; _Move(ix1-1,y2) ; _Draw(p-1,y2) ; _Draw(p-1,y1+1)
  458.  
  459.       x1 := p
  460.    ENDIF
  461.  
  462.    IF (obj.button_zoom = NIL) AND (obj.button_depth = NIL)
  463.       _APen(shine)   ; _Move(ix2+1,y2) ; _Draw(ix2+1,y1) ; _Draw(x2-1,y1)
  464.       _APen(shadow)  ; _Move(x2,y2)    ; _Draw(x2,y1+1)
  465.       _APen(fill)    ; _Plot(x2,y1)    ; _Boxf(ix2+2,y1+1,x2-1,y2) ; x2 := ix2
  466.    ELSE ; p := x2
  467.       _APen(fill) ; _Plot(ix2+1,iy1-1)
  468.       IF o := obj.button_depth
  469.          p := priv_ClearAround(rp,p,y1,y2,obj,o,fill,FALSE)
  470.          IF obj.button_zoom THEN _APen(fill) BUT _Boxf(p-1,y1,p+1,y2)
  471.       ENDIF
  472.       IF o := obj.button_zoom THEN p := priv_ClearAround(rp,p,y1,y2,obj,o,fill,FALSE)
  473.  
  474.       _APen(shine)   ; _Move(p+1,y2-1) ; _Draw(p+1,y1) ; _Draw(x2-1,y1)
  475.       _APen(shadow)  ; _Move(ix2,y2)   ; _Draw(p+2,y2)
  476.                      ; _Move(x2,y2)    ; _Draw(x2,y1+1)
  477.       x2 := p
  478.    ENDIF
  479.  
  480.    _APen(dark)    ; _Move(x1,y1)    ; _Draw(x1,y2)
  481.                   ; _Move(x2,y1)    ; _Draw(x2,y2)
  482.    _APen(fill)    ; _Plot(x1-1,y1)  ; IF (obj.button_depth <> NIL) OR (obj.button_zoom <> NIL) THEN _Plot(x2+1,y2)
  483.  
  484.    obj.barrect.x1 := x1 + 1 ; obj.barrect.y1 := y1
  485.    obj.barrect.x2 := x2 - 1 ; obj.barrect.y2 := y2
  486.  
  487.    wr_DrawTitleBar(obj)
  488. ENDPROC
  489.  
  490. PROC wr_DrawTitleBar(obj:PTR TO mydata)
  491.    DEF x1,y1,x2,y2,wt,td:PTR TO feelinTextDisplay,tw,p,rp:PTR TO rastport,
  492.        pn:PTR TO LONG,shine,halfshine,fill,halfshadow,shadow,halfdark,
  493.        td_Draw:FS_TextDisplay_Draw,rect:feelinRect,
  494.  
  495.        prep
  496.  
  497.    x1 := obj.barrect.x1 ; x2 := obj.barrect.x2 ; wt := F_Get(obj.render.windowobject,FA_Window_Title)
  498.    y1 := obj.barrect.y1 ; y2 := obj.barrect.y2 ; td := obj.textdisplay
  499.                                                ; rp := obj.render.rport
  500.  
  501.    prep := IF F_Get(obj.render.windowobject,FA_Window_Active) THEN obj.aprep ELSE obj.iprep
  502.  
  503.    IF (x2 < x1) OR (y2 < y1) OR (rp = NIL) THEN RETURN
  504.  
  505.    pn := obj.pens
  506.    shine       := pn[FV_Pen_Shine]
  507.    halfshine   := pn[FV_Pen_HalfShine]
  508.    fill        := pn[FV_Pen_Fill]
  509.    halfshadow  := pn[FV_Pen_HalfShadow]
  510.    shadow      := pn[FV_Pen_Shadow]
  511.    halfdark    := pn[FV_Pen_HalfDark]
  512.    obj.render.pens := pn
  513.  
  514.    IF (td <> NIL) AND (wt <> NIL)
  515.       F_DoA(td,FM_Set,[
  516.                FA_TextDisplay_PreParse,   prep,
  517.                FA_TextDisplay_Contents,   wt,
  518.                FA_TextDisplay_Font,       obj.font,
  519.                NIL])
  520.  
  521.       rect.x1 := x1 + TITLEX1 ; rect.x2 := x2 - TITLEX2
  522.       rect.y1 := y1 + TITLEY1 ; rect.y2 := y2 - TITLEY2
  523.  
  524.       F_DoA(td,FM_TextDisplay_Size,{rect})
  525.       tw := td.nWidth
  526.  
  527.       _APen(fill)    ; _Plot(x1,y2)   ; _Boxf(x1+1,y1+1,rect.x1 + tw - 1,y2-1)
  528.       _APen(shine)   ; _Move(x1,y2-1) ; _Draw(x1,y1) ; _Draw(rect.x1 + tw - 1,y1)
  529.       _APen(shadow)  ; _Move(x1+1,y2) ; _Draw(rect.x1 + tw - 1,y2)
  530.  
  531.       td_Draw.rect   := rect
  532.       td_Draw.render := obj.render
  533.  
  534.       F_DoA(td,FM_TextDisplay_Draw,td_Draw)
  535.  
  536.       x1 := rect.x1 + tw
  537.    ELSE
  538.       _APen(shine)   ; _Move(x1,y2-1) ; _Draw(x1,y1) ; _Draw(x1 + TITLEX1 - 1,y1)
  539.       _APen(shadow)  ; _Move(x1+1,y2) ; _Draw(x1 + TITLEX1 - 1,y2)
  540.       _APen(fill)    ; _Plot(x1,y2)   ; _Boxf(x1+1,y1+1,x1 + TITLEX1 - 1,y2-1)
  541.  
  542.       x1 += TITLEX1
  543.    ENDIF
  544.  
  545.    IF y2 - y1 + 1 + 20 + x1 > x2
  546.       _APen(fill)    ; _Plot(x2,y1) ; _Boxf(x1,y1+1,x2-1,y2-1)
  547.       _APen(shine)   ; _Move(x1,y1) ; _Draw(x2-1,y1)
  548.       _APen(shadow)  ; _Move(x1,y2) ; _Draw(x2,y2) ; _Draw(x2,y1+1)
  549.    ELSE
  550.       INC y1 ; DEC y2 ; DEC x2 ; p := y2 - y1 + 1
  551.  
  552.       _APen(shine)      ; _Move(x1,y1-1) ; _Draw(x1 + p,y1-1)
  553.       _APen(halfshadow) ; _Plot(x2+1,y1-1)
  554.  
  555.       SaveSP(x2)
  556.  
  557.       x2 := x1 + p - 1 ; _APen(fill)
  558.  
  559.       FOR tw := y1 TO y2
  560.          _Move(x1,tw) ; _Draw(x2,tw) ; DEC x2
  561.       ENDFOR
  562.  
  563.       LoadSP(x2)
  564.  
  565.       INC x1
  566.  
  567.       x1 := priv_Oblique(rp,x1,y1,y2,1,5,pn)
  568.       x1 := priv_Oblique(rp,x1,y1,y2,2,5,pn)
  569.       x1 := priv_Oblique(rp,x1,y1,y2,3,5,pn)
  570.       x1 := priv_Oblique(rp,x1,y1,y2,4,5,pn)
  571.  
  572.       _APen(halfshine)  ; _Move(x1+p,y1 - 1) ; _Draw(x2,y1-1)
  573.       _APen(halfdark)   ; _Move(x1-1,y2+1)   ; _Draw(x2+1,y2+1) ; _Draw(x2+1,y1)
  574.  
  575.       SaveSP(x2)
  576.  
  577.       x2 := x1 + p - 1 ; _APen(halfshadow)
  578.  
  579.       FOR tw := y2 TO y1 STEP -1
  580.          _Move(x1,tw) ; _Draw(x2,tw) ; INC x1
  581.       ENDFOR
  582.  
  583.       LoadSP(x2)
  584.  
  585.       _Boxf(x1,y1,x2,y2)
  586.    ENDIF
  587. ENDPROC
  588. PROC priv_Oblique(rp,x1,y1,y2,n,s,pn:PTR TO LONG)
  589.    DEF w,i
  590.  
  591.    w := y2 - y1 + 1
  592.  
  593.    FOR i := 1 TO n
  594.       _APen(pn[FV_Pen_HalfShadow])  ; _Move(x1,y2) ; _Draw(x1+w-1,y1)
  595.       _APen(pn[FV_Pen_HalfShine])   ; _Plot(x1+w,y1-1)
  596.       _APen(pn[FV_Pen_HalfDark])    ; _Plot(x1-1,y2+1)
  597.       INC x1
  598.    ENDFOR
  599.  
  600.    FOR n := i TO s
  601.       _APen(pn[FV_Pen_Fill])     ; _Move(x1,y2) ; _Draw(x1+w-1,y1)
  602.       _APen(pn[FV_Pen_Shine])    ; _Plot(x1+w,y1-1)
  603.       _APen(pn[FV_Pen_Shadow])   ; _Plot(x1-1,y2+1)
  604.       INC x1
  605.    ENDFOR
  606. ENDPROC x1
  607.  
  608. ->-- My Image Class --<------------------------------------------------------
  609.  
  610. PROC image_dispatcher(ic=A0:PTR TO iclass,obj=A2:PTR TO image,msg=A1:PTR TO impdraw)
  611.    DEF data:PTR TO myimagedata,rp,
  612.        x1,y1,x2,y2,a,b,
  613.        pn:PTR TO LONG,p1,p2,p3,shine,halfshine,fill,halfshadow,shadow,halfdark,dark,
  614.        f0,f1
  615.  
  616.    sys_RGlob() ; data := obj + ic.instoffset
  617.  
  618.    IF msg.methodid = IM_DRAW
  619.       rp := msg.rport
  620.       pn := data.renderer.activepens
  621.       x1 := msg.offsetx + obj.leftedge ; x2 := x1 + obj.width - 1
  622.       y1 := msg.offsety + obj.topedge  ; y2 := y1 + obj.height - 1
  623.  
  624.       p1          := data.renderer.pens[FV_Pen_HalfShine]
  625.       p2          := data.renderer.pens[FV_Pen_HalfShadow]
  626.       p3          := data.renderer.pens[FV_Pen_Fill]
  627.       shine       := pn[FV_Pen_Shine]
  628.       halfshine   := pn[FV_Pen_HalfShine]
  629.       fill        := pn[FV_Pen_Fill]
  630.       halfshadow  := pn[FV_Pen_HalfShadow]
  631.       shadow      := pn[FV_Pen_Shadow]
  632.       halfdark    := pn[FV_Pen_HalfDark]
  633.       dark        := pn[FV_Pen_Dark]
  634.  
  635.       f0 := `priv_Bevel(rp,x1,y1,x2,y2,p2,p1,p3)
  636.       f1 := `priv_Glow(rp,x1+1,y1+1,x2-1,y2-1,pn)
  637.  
  638.       SELECT data.type
  639.          CASE FV_GadgetType_Close
  640.             IF msg.state == [IDS_NORMAL,IDS_INACTIVENORMAL]
  641.                Eval(f0) ; priv_Shape(rp,x1+1,y1+1,x2-1,y2-1,pn)
  642.             ELSEIF msg.state = IDS_SELECTED
  643.                Eval(f0) ; Eval(f1)
  644.             ENDIF
  645.  
  646.          CASE FV_GadgetType_Iconify
  647.             _APen(3)
  648.             _Boxf(x1,y1,x2,y2)
  649.  
  650.          CASE FV_GadgetType_Zoom
  651.             IF msg.state == [IDS_NORMAL,IDS_INACTIVENORMAL]
  652.                Eval(f0) ; priv_Shape(rp,x1+1,y1+1,x2-1,y2-1,pn)
  653.  
  654.                INC x1 ; INC y1 ; DEC x2 ; DEC y2
  655.  
  656.                a := x2 - x1 + 1 / 2
  657.                b := y2 - y1 + 1 / 2
  658.  
  659.                priv_Shape(rp,x1,y1,x1+a+1,y1+b+1,pn)
  660.             ELSEIF msg.state = IDS_SELECTED
  661.                Eval(f0) ; Eval(f1)
  662.             ENDIF
  663.  
  664.          CASE FV_GadgetType_Depth
  665.             IF msg.state == [IDS_NORMAL,IDS_INACTIVENORMAL]
  666.                _APen(p3) ; _Boxf(x1,y1,x2,y2)
  667.                INC x1 ; INC y1 ; DEC x2 ; DEC y2
  668.  
  669.                a := x2 - x1 + 1 / 2
  670.                b := y2 - y1 + 1 / 2
  671.  
  672.                priv_Bevel(rp,x1-1,y1-1,x1+a+3,y1+b+3,p2,p1,p3)
  673.                priv_Bevel(rp,x2-a-3,y2-b-3,x2+1,y2+1,p2,p1,p3)
  674.                priv_Shape(rp,x2-a-2,y2-b-2,x2,y2,pn)
  675.                priv_Shape(rp,x1,y1,x1+a+2,y1+b+2,pn)
  676.             ELSEIF msg.state = IDS_SELECTED
  677.                _APen(fill) ; _Boxf(x1,y1,x2,y2)
  678.                INC x1 ; INC y1 ; DEC x2 ; DEC y2
  679.  
  680.                a := x2 - x1 + 1 / 2
  681.                b := y2 - y1 + 1 / 2
  682.  
  683.                priv_Bevel(rp,x1-1,y1-1,x1+a+3,y1+b+3,halfshadow,halfshine,fill)
  684.                priv_Bevel(rp,x2-a-3,y2-b-3,x2+1,y2+1,halfshadow,halfshine,fill)
  685.                priv_Glow(rp,x1,y1,x1+a+2,y1+b+2,pn)
  686.                priv_Glow(rp,x2-a-2,y2-b-2,x2,y2,pn)
  687.             ENDIF
  688.       ENDSELECT
  689.    ELSE
  690.       RETURN DoSuperMethodA(ic,obj,msg)
  691.    ENDIF
  692. ENDPROC 
  693.  
  694. ->-- Private --<-------------------------------------------------------------
  695.  
  696. PROC priv_Bevel(rp,x1,y1,x2,y2,p1,p2,p3)
  697.    _APen(p1) ; _Move(x1,y2-1) ; _Draw(x1,y1) ; _Draw(x2-1,y1)
  698.    _APen(p2) ; _Move(x1+1,y2) ; _Draw(x2,y2) ; _Draw(x2,y1+1)
  699.    _APen(p3) ; _Plot(x1,y2)   ; _Plot(x2,y1)
  700. ENDPROC
  701. PROC priv_Box(rp,x1,y1,x2,y2)
  702.    _Move(x1,y2) ; _Draw(x1,y1) ; _Draw(x2,y1) ; _Draw(x2,y2) ; _Draw(x1,y2)
  703. ENDPROC
  704. PROC priv_Shape(rp,x1,y1,x2,y2,pn:PTR TO LONG)
  705.    DEF halfshine,halfshadow,fill
  706.  
  707.    IF (x1 > x2) AND (y1 > y2) THEN RETURN
  708.  
  709.    halfshine  := pn[FV_Pen_HalfShine]
  710.    halfshadow := pn[FV_Pen_HalfShadow]
  711.    fill       := pn[FV_Pen_Fill]
  712.  
  713.    _APen(pn[FV_Pen_HalfDark])
  714.    _Box(x1,y1,x2,y2)
  715.  
  716.    _APen(fill)
  717.    IF (x1+2 <= x2-2) AND (y1+2 <= y2-2) THEN _Boxf(x1+2,y1+2,x2-2,y2-2)
  718.    priv_Bevel(rp,x1+1,y1+1,x2-1,y2-1,halfshine,halfshadow,fill)
  719. ENDPROC
  720. PROC priv_Glow(rp,x1,y1,x2,y2,pn:PTR TO LONG)
  721.    IF (x1 > x2) AND (y1 > y2) THEN RETURN
  722.  
  723.    _APen(pn[FV_Pen_HalfDark])   ;  _Box(x1,y1,x2,y2)
  724.  
  725.    INC x1 ; INC y1 ; DEC x2 ; DEC y2
  726.  
  727.    _APen(pn[FV_Pen_HalfShadow]) ; _Boxf(x1,y1,x2,y2)
  728.    _APen(pn[FV_Pen_Shine])      ; _Plot(x1,y1)
  729.                                 ; _Move(x2-2,y2) ; _Draw(x2,y2) ; _Draw(x2,y2-2)
  730.    _APen(pn[FV_Pen_Shadow])     ; _Move(x1,y2-1) ; _Draw(x1,y1+2) ; _Draw(x1+2,y1) ; _Draw(x2-1,y1)
  731.                                 ; _Plot(x1+1,y1+2) ; _Plot(x1+2,y1+1)
  732.    _APen(pn[FV_Pen_HalfShine])  ; _Move(x1+1,y2) ; _Draw(x2-3,y2) ; _Draw(x2,y2-3) ; _Draw(x2,y1+1) ; _Plot(x2-1,y2-1)
  733. ENDPROC
  734. PROC priv_ClearAround(rp,x,y1,y2,obj:PTR TO mydata,g:PTR TO gadget,fill,forward)
  735.    DEF x1,x2,w,i
  736.  
  737.    w := TICKNESS * 2 + obj.gadw
  738.  
  739.    IF forward
  740.       x1 := x ; x2 := x + w - 1
  741.    ELSE
  742.       x1 := x - w + 1 ; x2 := x
  743.    ENDIF
  744.  
  745.    _APen(fill)
  746.    _Boxf(x1+1,y1+1,x2-1,y2-1)
  747.  
  748.    IF i := g.gadgetrender THEN DrawImageState(rp,i,x1 + TICKNESS, y1 + TITLEY1, IDS_NORMAL,NIL)
  749.  
  750.    RETURN IF forward THEN x2 + 1 ELSE x1 - 1
  751. ENDPROC
  752.  
  753. /*
  754. ->PROC Iconify
  755.       IF i := NewObjectA(ic,NIL,[IA_WIDTH,obj.gadw, IA_HEIGHT,obj.gadh, NIL])
  756.          obj.image_iconify := i
  757.  
  758.          d          := i + ic.instoffset
  759.          d.renderer := obj
  760.          d.type     := FV_GadgetType_Iconify
  761.  
  762.          IF o := NewObjectA(NIL,'buttongclass',[
  763.             GA_WIDTH,obj.gadw,
  764.             GA_HEIGHT,obj.gadh,
  765.             GA_RELVERIFY,TRUE,
  766.             GA_SYSGTYPE,GTYP_CLOSE,
  767.             GA_TOPBORDER,TRUE,
  768.             GA_IMAGE, i, NIL])
  769.  
  770.             obj.button_iconify := o
  771.          ELSE
  772.             RETURN
  773.          ENDIF
  774.       ELSE
  775.          RETURN
  776.       ENDIF
  777. ->ENDPROC
  778. */
  779.